<template>
    <div class="user">
        <Header/>
        <ul>
            <li v-for="(item,index) in courseList" :key="index">
                <div class="row">
                    <div class="col-5">
                        <a :href="'/user?id=' + item.id +'&name='+ item.title ">
                            <img :src="item.avater" class="img-fluid" :alt="item.title">
                        </a>
                        <p>{{item.title }}</p>
                    </div>
                    <div class="col-7">{{ item.price }}</div>
                </div>
            </li>
        </ul>
        <Footer/>
    </div>
</template>

<script>

    import Header from '../components/Header.vue'
    import Footer from "../components/Footer.vue";
    var qs = require('qs');
    export default {
        name: "User",

        components: {
            Header,
            Footer
        },
        data() {
            return {
                course: [],
                courseList: [],
                column: [],
            }
        },
        created() {
            this.demo();
            this.getCourse();
            this.postMessage();
        },
        mounted() {
            console.log(this.$route.query);
        },
        methods: {
            demo: function () {
                this.$http.get(this.$Url + '/api/v1/column')
                    .then(res => {
                        this.column = res.data.data.column;
                        this.courseList = res.data.data.courseList;
                        console.log(this.$route.query);
                    }).catch(function (res) {
                    console.log(res)
                });
            },
            getCourse: function () {
                this.$http.get(this.$Url+'/api/v1/course')
                    .then(res => {
                        this.course = res.data.data.course;
                        console.log(res)
                    }).catch(function (res) {
                    console.log(res)
                });
            },
            postMessage: function () {
                this.$http.post('http://www.yzkt.my',qs.stringify({
                    name:this.$route.query.name,
                    id:this.$route.query.id
                })).then(res => {
                    console.log(res);
                }).catch(function (res) {
                    console.log(res);
                })
            }
        }

    }
</script>

<style scoped>

</style>